package ink.lovejinhu.swardToOffer;

/**
 * @author jinhu
 * created 2021-08-11 17:51
 */
public class Offer_011 {
    /**
     * 旋转数组中最小元素
     * <p>
     * 实际上是个类似勾的函数
     *
     * @param numbers
     * @return
     */
    public int minArray(int[] numbers) {
        int res = Integer.MIN_VALUE;
        for (int i = 0; i < numbers.length - 1; i++) {
            if (numbers[i] > numbers[i + 1]) {
                res = numbers[i + 1];
                break;
            }
        }
        return res == Integer.MIN_VALUE ? numbers[0] : res;
    }
}
